#tag Window
Begin Window Window1
   BackColor       =   16777215
   Backdrop        =   ""
   BalloonHelp     =   ""
   CloseButton     =   True
   Composite       =   True
   Frame           =   0
   FullScreen      =   False
   HasBackColor    =   False
   Height          =   453
   ImplicitInstance=   True
   LiveResize      =   False
   MacProcID       =   0
   MaxHeight       =   32000
   MaximizeButton  =   True
   MaxWidth        =   32000
   MenuBar         =   1678936063
   MenuBarVisible  =   True
   MinHeight       =   64
   MinimizeButton  =   True
   MinWidth        =   64
   Placement       =   0
   Resizeable      =   True
   Title           =   "Mini Browser"
   Visible         =   True
   Width           =   621
   Begin EditField AddrField
      AcceptTabs      =   ""
      Alignment       =   0
      AutoDeactivate  =   True
      BackColor       =   16777215
      Bold            =   ""
      Border          =   True
      DataField       =   ""
      DataSource      =   ""
      Enabled         =   True
      Format          =   ""
      Height          =   22
      HelpTag         =   ""
      Index           =   2147483648
      InitialParent   =   ""
      Italic          =   ""
      Left            =   79
      LimitText       =   0
      LockBottom      =   False
      LockLeft        =   True
      LockRight       =   True
      LockTop         =   True
      Mask            =   ""
      Multiline       =   ""
      Password        =   ""
      ReadOnly        =   ""
      Scope           =   0
      ScrollbarHorizontal=   ""
      ScrollbarVertical=   True
      Styled          =   ""
      TabIndex        =   0
      TabPanelIndex   =   0
      Text            =   "http://www.realsoftware.com/"
      TextColor       =   0
      TextFont        =   "System"
      TextSize        =   0
      Top             =   11
      Underline       =   ""
      UseFocusRing    =   True
      Visible         =   True
      Width           =   484
      BehaviorIndex   =   0
   End
   Begin PushButton GoButton
      AutoDeactivate  =   True
      Bold            =   ""
      Cancel          =   ""
      Caption         =   "Go"
      Default         =   ""
      Enabled         =   True
      Height          =   20
      HelpTag         =   ""
      Index           =   2147483648
      InitialParent   =   ""
      Italic          =   ""
      Left            =   575
      LockBottom      =   ""
      LockLeft        =   ""
      LockRight       =   True
      LockTop         =   True
      Scope           =   0
      TabIndex        =   1
      TabPanelIndex   =   0
      TextFont        =   "System"
      TextSize        =   0
      Top             =   13
      Underline       =   ""
      Visible         =   True
      Width           =   37
      BehaviorIndex   =   1
   End
   Begin HTMLViewer HTMLViewer1
      AutoDeactivate  =   True
      ControlOrder    =   2
      Enabled         =   True
      Height          =   350
      HelpTag         =   ""
      Index           =   2147483648
      InitialParent   =   ""
      Left            =   7
      LockBottom      =   True
      LockLeft        =   True
      LockRight       =   True
      LockTop         =   True
      Scope           =   0
      TabIndex        =   0
      TabPanelIndex   =   0
      Top             =   45
      Visible         =   True
      Width           =   606
      BehaviorIndex   =   2
   End
   Begin ComboBox ComboBox1
      AutoComplete    =   False
      AutoDeactivate  =   True
      Bold            =   ""
      DataField       =   ""
      DataSource      =   ""
      Enabled         =   True
      Height          =   20
      HelpTag         =   ""
      Index           =   2147483648
      InitialParent   =   ""
      InitialValue    =   ""
      Italic          =   ""
      Left            =   7
      ListIndex       =   0
      LockBottom      =   True
      LockLeft        =   True
      LockRight       =   True
      LockTop         =   ""
      Scope           =   0
      TabIndex        =   3
      TabPanelIndex   =   0
      TextFont        =   "System"
      TextSize        =   0
      Top             =   425
      Underline       =   ""
      UseFocusRing    =   True
      Visible         =   True
      Width           =   606
      BehaviorIndex   =   3
   End
   Begin StaticText StatusLbl
      AutoDeactivate  =   True
      Bold            =   ""
      DataField       =   ""
      DataSource      =   ""
      Enabled         =   True
      Height          =   20
      HelpTag         =   ""
      Index           =   2147483648
      InitialParent   =   ""
      Italic          =   ""
      Left            =   7
      LockBottom      =   True
      LockLeft        =   True
      LockRight       =   True
      LockTop         =   ""
      Multiline       =   ""
      Scope           =   0
      TabIndex        =   4
      TabPanelIndex   =   0
      Text            =   ""
      TextAlign       =   0
      TextColor       =   0
      TextFont        =   "System"
      TextSize        =   0
      Top             =   397
      Underline       =   ""
      Visible         =   True
      Width           =   606
      BehaviorIndex   =   4
   End
   Begin PushButton backButton
      AutoDeactivate  =   True
      Bold            =   ""
      Cancel          =   ""
      Caption         =   "Back"
      Default         =   ""
      Enabled         =   False
      Height          =   20
      HelpTag         =   ""
      Index           =   2147483648
      InitialParent   =   ""
      Italic          =   ""
      Left            =   7
      LockBottom      =   ""
      LockLeft        =   ""
      LockRight       =   ""
      LockTop         =   ""
      Scope           =   0
      TabIndex        =   5
      TabPanelIndex   =   0
      TextFont        =   "System"
      TextSize        =   0
      Top             =   11
      Underline       =   ""
      Visible         =   True
      Width           =   30
      BehaviorIndex   =   5
   End
   Begin PushButton FwdButton
      AutoDeactivate  =   True
      Bold            =   ""
      Cancel          =   ""
      Caption         =   "Fwd"
      Default         =   ""
      Enabled         =   False
      Height          =   20
      HelpTag         =   ""
      Index           =   2147483648
      InitialParent   =   ""
      Italic          =   ""
      Left            =   43
      LockBottom      =   ""
      LockLeft        =   ""
      LockRight       =   ""
      LockTop         =   ""
      Scope           =   0
      TabIndex        =   6
      TabPanelIndex   =   0
      TextFont        =   "System"
      TextSize        =   0
      Top             =   11
      Underline       =   ""
      Visible         =   True
      Width           =   30
      BehaviorIndex   =   6
   End
   Begin HistoryClass URLhistory
      Height          =   32
      Index           =   2147483648
      Left            =   168
      Scope           =   0
      TabPanelIndex   =   0
      Top             =   370
      Width           =   32
      BehaviorIndex   =   7
   End
End
#tag EndWindow

#tag WindowCode
	#tag MenuHandler
		Function FileQuit() As Boolean Handles FileQuit.Action
			Quit
		End Function
#tag EndMenuHandler


	#tag Method, Flags = &h21
		Private Sub Report(s as String)
		  //Used for Tracing events while designing / debugging
		  Dim d As New Date
		  ComboBox1.AddRow s + " " + d.ShortTime
		End Sub
	#tag EndMethod


	#tag Property, Flags = &h21
		Private cancelling As Boolean
	#tag EndProperty


#tag EndWindowCode

#tag Events AddrField
	#tag Event
		Function KeyDown(Key As String) As Boolean
		  //Accept Return key as "Go"
		  if (key = chr(3) or Key = chr(13)) and len(AddrField.Text) > 0 then
		    HTMLViewer1.LoadURL AddrField.Text
		  End If
		End Function
	#tag EndEvent
#tag EndEvents
#tag Events GoButton
	#tag Event
		Sub Action()
		  HTMLViewer1.LoadURL AddrField.Text
		End Sub
	#tag EndEvent
#tag EndEvents
#tag Events HTMLViewer1
	#tag Event
		Function CancelLoad(URL as String) As Boolean
		  Dim maxHist as Integer
		  Dim lcUrl as String
		  //Report "CancelLoad "+ URL
		  lcUrl = Lowercase(URL)
		  //Some random Whitelist code to allow a few URLs for testing
		  'If InStr(lcUrl,"real") = 0 and InStr(lcUrl,"garman") = 0 and InStr(lcUrl,"google") = 0 Then
		  'AddrField.Text = URLhistory.prevAddressBar
		  'cancelling = True
		  'MsgBox url + " refused"
		  'Return True
		  'End If
		  cancelling = false
		  URLhistory.Add URL
		  backButton.Enabled= URLhistory.validBack
		  FwdButton.Enabled=URLhistory.validFwd
		End Function
	#tag EndEvent
	#tag Event
		Sub Close()
		  //Report "Close"
		End Sub
	#tag EndEvent
	#tag Event
		Sub DocumentBegin(URL as String)
		  //Report "DocumentBegin " + URL
		  //Display URL with visual clue we haven't finished loading
		  If Not cancelling then
		    AddrField.Text = ". . . " + URL
		  End If
		End Sub
	#tag EndEvent
	#tag Event
		Sub DocumentComplete(URL as String)
		  //Report "DocumentComplete " + URL
		  //Display URL without leading ". . ." displayed when loading
		  AddrField.Text = URL
		  //Save URL from address bar in case next URL is cancelled
		  URLhistory.prevAddressBar = URL
		End Sub
	#tag EndEvent
	#tag Event
		Sub DocumentProgressChanged(URL as String, percentageComplete as Integer)
		  //Report "DocumentProgressChange " + URL + " " + str(percentageComplete) + "%"
		  //Consider adding a progress bar
		  
		End Sub
	#tag EndEvent
	#tag Event
		Sub Error(errorNumber as Integer, errorMessage as String)
		  //Report "Error " + str(errorNumber) + " " + errorMessage
		End Sub
	#tag EndEvent
	#tag Event
		Function NewWindow() As HTMLViewer
		  //Report "NewWindow"
		  //Popup or contextual-click - Make sure user knows.
		  If MsgBox("OK to open new window?",36,"PopUp Blocker") = 7 then
		    Return Nil
		  End If
		  //User is happy, so give him a new window
		  dim x as New Window1
		  Return x.HTMLViewer1
		End Function
	#tag EndEvent
	#tag Event
		Sub Open()
		  //Report "Open"
		End Sub
	#tag EndEvent
	#tag Event
		Sub SecurityChanged(isSecure as Boolean)
		  //dim s as String
		  //if isSecure Then
		  //s ="Secure"
		  //Else
		  //s ="Insecure"
		  //End If
		  //Report "SecurityChanged " + s
		End Sub
	#tag EndEvent
	#tag Event
		Sub StatusChanged(newStatus as String)
		  //Report "StatusChanged" + " " + newStatus
		  StatusLbl.Text = newStatus
		End Sub
	#tag EndEvent
	#tag Event
		Sub TitleChanged(newTitle as String)
		  //Report "TitleChanged " + newTitle
		  Self.Title = newTitle
		End Sub
	#tag EndEvent
#tag EndEvents
#tag Events backButton
	#tag Event
		Sub Action()
		  HTMLViewer1.LoadURL URLhistory.Back
		  backButton.Enabled = URLhistory.validBack
		  FwdButton.Enabled = URLhistory.validFwd
		End Sub
	#tag EndEvent
#tag EndEvents
#tag Events FwdButton
	#tag Event
		Sub Action()
		  HTMLViewer1.LoadURL URLhistory.Fwd
		  backButton.Enabled = URLhistory.validBack
		  FwdButton.Enabled = URLhistory.validFwd
		End Sub
	#tag EndEvent
#tag EndEvents
